<?php
// Ham them gia tri va the vao xau chua gia tri cua form
//$p_xml_string: Chuoi van dua them the vao
//$p_xml_tag   : The muon dua vao
//$p_xml_value : Gia tri cua the muon dua vao
function _add_tag_and_value_in_xml_string($p_xml_string,$p_xml_tag,$p_xml_value){
	$strXML = '<?xml version="1.0" encoding="UTF-8"?><root><data_list></data_list></root>';
	if (!is_null($p_xml_string) && $p_xml_string!=""){
		//Xoa the va gia tri cua the $p_xml_tag trong xau truyen vao
		$p_xml_string = preg_replace ("'<".$p_xml_tag."[^>]*?>.*?</".$p_xml_tag.">'si", "", $p_xml_string);
		
		$strXML = substr($p_xml_string,0,strlen($p_xml_string)-strlen("</data_list></root>"));
		$strXML.= "<".$p_xml_tag.">".$p_xml_value."</".$p_xml_tag.">";
		$strXML.= "</data_list></root>";
	}
	return $strXML;
}
// Ham Thay the cac the cac gia tri trong cau lenh Query du lieu
//$p_sql_replace  : Chuoi can thay the
//$p_xml_string_in_file  : chuoi XML mo ta cac tieu thuc loc
//$p_xml_tag : The XML can lay trong chuoi XMl mo ta tieu thuc loc
//$p_filter_xml_string  : chuoi XML gom cac the va gia tri cua tung tieu thuc loc do.

function _replace_tag_xml_value_in_sql($p_sql_replace,$p_xml_string_in_file,$p_xml_tag,$p_filter_xml_string){
	global $_ISA_OWNER_CODE;
	$p_sql_replace = str_replace('#OWNER_CODE#' ,$_ISA_OWNER_CODE,$p_sql_replace);	
	$v_sql_replace_temp = $p_sql_replace;
	$v_xml_file_temp = $p_xml_string_in_file;
	$v_table_struct_rax = new RAX(); 
	$v_table_struct_rec = new RAX(); 
	$v_table_struct_rax->open($p_xml_string_in_file);
	$v_table_struct_rax->record_delim = $p_xml_tag;
	$v_table_struct_rax->parse();
	$v_table_struct_rec = $v_table_struct_rax->readRecord(); 
	while ($v_table_struct_rec) { 
		$v_table_struct_row = $v_table_struct_rec->getRow();
		$v_tag_list = $v_table_struct_row["tag_list"];
		$arr_tag = explode(",", $v_tag_list);
		for($i=0;$i < sizeof($arr_tag); $i++){
			$v_formfield_rax = new RAX(); 
			$v_formfield_rec = new RAX(); 
			$v_formfield_rax->open($v_xml_file_temp);
			$v_formfield_rax->record_delim = $arr_tag[$i];
			$v_formfield_rax->parse();
			$v_formfield_rec = $v_formfield_rax->readRecord(); 			
			$v_formfield_row = $v_formfield_rec->getRow(); 
			$v_data_format = $v_formfield_row["data_format"];
			$v_xml_tag_in_db = $v_formfield_row["xml_tag_in_db"];
			if ($p_filter_xml_string!=""){
				$v_column_rax = new RAX(); 
				$v_column_rec = new RAX();
				$v_column_rax->open($p_filter_xml_string);
				$v_column_rax->record_delim = 'data_list';
				$v_column_rax->parse();
				$v_column_rec = $v_column_rax->readRecord(); 
				$v_column_row = $v_column_rec->getRow();
				$v_value_input = $v_column_row[$v_xml_tag_in_db];
				if ($v_data_format=="isdate"){
					$v_value_input = _ddmmyyyy_to_yyyymmdd($v_value_input);
				}
			}
			$v_sql_replace_temp = str_replace("#".$v_xml_tag_in_db."#",$v_value_input,$v_sql_replace_temp);
		}
		$v_table_struct_rec = $v_table_struct_rax->readRecord();
	}
	return  $v_sql_replace_temp;
}

// Thay the cac bien trong cau lenh SQL bang cac gia tri duoc luu trong 1 chuoi XML
// p_sql: Chuoi lenh SQL
// p_variable: ten bien can thay the
// p_xml_str: Chuoi XML luu chua gia tri thay the duoi dang cac the XML
// p_xml_parent_tag: Ten the XML (laf the "cha") cua the XML chua gia tri thay the
// p_xml_tag: ten the XML chua gia tri se thay the
function _replace_variable_value_in_sql($p_sql,$p_variable, $p_xml_string, $p_xml_parent_tag, $p_xml_tag){
	$v_replace_value = _XML_get_xml_tag_value($p_xml_string,$p_xml_parent_tag,$p_xml_tag);
	$v_sql_string = str_replace($p_variable,$v_replace_value,$p_sql);
	return $v_sql_string;
}

// Ham tao chuoix XML de ghi vao CSDL
// $p_xml_tag_list: danh sach cac the XML (phan cach boi _CONST_SUB_LIST_DELIMITOR)
// $p_value_list: danh sach cac gia tri tuong ung voi moi the XML (phan cach boi _CONST_SUB_LIST_DELIMITOR)
function _XML_generate_xml_data_tring($p_xml_tag_list,$p_value_list){
	$strXML = '<?xml version="1.0" encoding="UTF-8"?><root><data_list>';
	for ($i=0;$i<_list_get_len($p_xml_tag_list,_CONST_SUB_LIST_DELIMITOR);$i++){
		$strXML = $strXML ."<"._list_get_at($p_xml_tag_list,$i,_CONST_SUB_LIST_DELIMITOR).">";
		$strXML = $strXML .trim(_replace_XML_bad_char(_list_get_at($p_value_list,$i,_CONST_SUB_LIST_DELIMITOR)));
		$strXML = $strXML ."</"._list_get_at($p_xml_tag_list,$i,_CONST_SUB_LIST_DELIMITOR).">";
	}
	$strXML = $strXML . "</data_list></root>";
	return $strXML;
}

// Ham _XML_read_record tra lai mot array chua ten cac the XML va gia tri tuong ung TRONG MOT NHANH cua file XML
// $p_xml_string: chuoi XML
// $p_xml_tag: ten the XML xac dinh nhanh can lay thong tin
// Gia tri tra lai: la mot array
// Vi du:
// $arr = _XML_read_record("../xml/quan_tri_doi_tuong_danh_muc.xml","listtype_type");
// var_dump($arr);

function _XML_read_record($p_xml_string,$p_xml_tag){
	if ($p_xml_string!=""){
		$rax = new RAX(); 
		$rec = new RAX(); 
		$rax->open($p_xml_string);
		$rax->record_delim = $p_xml_tag;
		$rax->parse();
		$rec = $rax->readRecord(); 
		return $rec;
	}else{
		return NULL;
	}
}
// Ham _XML_get_xml_tag_value tra lai GIA TI cua mot the XML
// $p_xml_file: tham so xac dịinh duong dan toi file XML
// $p_xml_parent_tag: ten the XML CHA  - xac dinh nhanh can lay thong tin
// $p_xml_tag: ten the XML can lay gia tri
// Vi du:
// $ret = _XML_get_xml_tag_value("../xml/quan_tri_doi_tuong_danh_muc.xml","listtype_type","label");
// echo $ret; 
function _XML_get_xml_tag_value($p_xml_string,$p_xml_parent_tag,$p_xml_tag){
	if ($p_xml_string!=""){
		$rec = new RAX(); 
		$rec = _XML_read_record($p_xml_string,$p_xml_parent_tag);
		$row = $rec->getRow();
		$v_ret = _restore_XML_bad_char($row[$p_xml_tag]);
	}else{
		$v_ret = "";
	}
	return $v_ret;
}

// $p_xml_file: duong dan toi file XML mo ta cac form field
// $p_xml_tag: ten THE XML xac dinh NHANH mo ta cac form field. Phai lay ten THE mo ta cau truc bang 
// $p_xml_string_in_db: xau XML lay tu CSDL
// $p_arr_item_value: array chua gia tri cua cac column
//$p_input_file_name: De xac dinh truyen vao xau xml hay ten file xml
// Vi du: echo _XML_generate_formfield("../xml/quan_tri_doi_tuong_danh_muc.xml", "update_row", $v_xml_str, $arr_single_list); 

function _XML_generate_formfield($p_xml_file, $p_xml_tag, $p_xml_string_in_db, $p_arr_item_value,$p_input_file_name=true){
	global $_ISA_IMAGE_URL_PATH,$_ISA_LIB_URL_PATH,$_ISA_WEB_SITE_PATH,$_ISA_OWNER_CODE;
	global $v_label, $v_type, $v_dataformat,$v_message,$v_optional,$v_xml_data,$v_column_name,$v_xml_tag_in_db,$v_readonly_in_edit_mode,$v_disabled_in_edit_mode,$v_note,$v_relate_recordtype,$v_width,$v_row, $v_row_id, $v_max, $v_min, $v_maxlength,$v_tooltip;
	global $v_selectbox_option_sql,$v_selectbox_id_column, $v_selectbox_name_column,$v_function_value,$v_the_first_of_id_value;
	global $v_checkbox_multiple_sql,$v_checkbox_multiple_id_column,$v_checkbox_multiple_name_column ;
	global $v_textbox_multiple_sql,$v_textbox_multiple_id_column,$v_textbox_multiple_name_column,$v_first_width; //Cac bien multipletextbox
	global $v_table_name, $v_order_column,$v_where_clause; //Cac bien textorder
	global $v_directory,$v_file_type;
	global $v_js_function_list,	$v_js_action_list;
	global $v_value,$i,$v_row,$v_row_id;
	global $v_xml_string_in_file;
	global $v_js_function_after_select,$v_path_root_to_modul;
	global $v_input_data,$v_session_name, $v_session_id_index,$v_session_name_index,$v_session_value_index;
	$v_html_str ="";
	if ($p_input_file_name){
		$v_xml_string_in_file = _read_file($p_xml_file);
	}
	$v_first_col_width = _XML_get_xml_tag_value($v_xml_string_in_file,"common_para","first_col_width");
	$v_second_col_width = (100-$v_first_col_width)."%";

	$rax = new RAX(); 
	$rec = new RAX(); 
	$rax->open($v_xml_string_in_file);
	$rax->record_delim = $p_xml_tag;
	$rax->parse();
	$rec = $rax->readRecord(); 
	while ($rec) { 
		$table_struct_row = $rec->getRow();
		$v_have_line_before = $table_struct_row["have_line_before"];
		$v_tag_list = $table_struct_row["tag_list"];
		$v_row_id = $table_struct_row["row_id"];
		if (isset($table_struct_row["repeat"])){
			$v_repeat = $table_struct_row["repeat"];
		}else{
			$v_repeat = 0;
		}
		
		$arr_tag = explode(",", $v_tag_list);
		if ($v_have_line_before=="true"){
			$v_html_str = $v_html_str . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr>";
			$v_html_str = $v_html_str . "<td><hr width='100%' color='#66CCFF' size='1'></td>";
			$v_html_str = $v_html_str . "</tr></table>";
		}
		//Bang chua mot dong cua form
		$v_html_str = $v_html_str . "<table width='100%'  border='0' cellspacing='0' cellpadding='0'>";
		
		$v_count = 0;
		do{
			$v_html_table = "";
			$v_html_tag = "";			
			for($i=0;$i < sizeof($arr_tag);$i++){
				$formfield_rax = new RAX(); 
				$formfield_rec = new RAX(); 
				$formfield_rax->open($v_xml_string_in_file);
				$formfield_rax->record_delim = $arr_tag[$i];
				$formfield_rax->parse();
				$formfield_rec = $formfield_rax->readRecord(); 
				$formfield_row = $formfield_rec->getRow(); 
				$v_label = $formfield_row["label"];
				$v_type = $formfield_row["type"];
				$v_dataformat = $formfield_row["data_format"];
				$v_input_data = $formfield_row["input_data"];
				$v_width = $formfield_row["width"];
				$v_row = $formfield_row["row"];
				$v_max = $formfield_row["max"];
				$v_min = $formfield_row["min"];
				$v_note = $formfield_row["note"];
				$v_message = $formfield_row["message"];
				$v_optional = $formfield_row["optional"];
				$v_maxlength = $formfield_row["maxlength"];
				$v_xml_data = $formfield_row["xml_data"];
				$v_column_name = $formfield_row["column_name"];
				$v_xml_tag_in_db = $formfield_row["xml_tag_in_db"];
				$v_js_function_list = $formfield_row["js_function_list"];
				$v_js_action_list = $formfield_row["js_action_list"];
				$v_relate_recordtype = $formfield_row["relate_recordtype"];
				$v_default_value = $formfield_row["default_value"];
				$v_path_root_to_modul = $formfield_row["path_root_to_module"];	
				$v_js_function_after_select = $formfield_row["js_function_after_select"];
				$v_readonly_in_edit_mode = $formfield_row["readonly_in_edit_mode"];
				$v_disabled_in_edit_mode = $formfield_row["disabled_in_edit_mode"];
				//lay du lieu tu session
				$v_session_name = $formfield_row["session_name"];
				$v_session_id_index = $formfield_row["session_id_index"];
				$v_session_name_index = $formfield_row["session_name_index"];
				$v_session_value_index = $formfield_row["session_value_index"];
				
				//Kiem tra neu ma form them moi thi cho phep nhap du lieu
				if (is_null($p_arr_item_value) || sizeof($p_arr_item_value)==0){
					$v_readonly_in_edit_mode = "false";
					$v_disabled_in_edit_mode = "false";
				}
				if ($v_repeat>0){
					$v_xml_tag_in_db = $v_xml_tag_in_db.$v_count;		
				}
				if ($p_xml_string_in_db!="" && $v_xml_data=="true"){
					$column_rax = new RAX(); 
					$column_rec = new RAX();
					$column_rax->open($p_xml_string_in_db);
					$column_rax->record_delim = 'data_list';
					$column_rax->parse();
					$column_rec = $column_rax->readRecord(); 
					$column_row = $column_rec->getRow();
					$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]); 
				}else{
					$v_value = $p_arr_item_value[$v_column_name];
				}
				
				//Dat gia gi mac dinh cho doi tuong
				if (trim($v_default_value)!= "" && (is_null($p_arr_item_value) || sizeof($p_arr_item_value)==0 || $p_arr_item_value["chk_save_and_add_new"]=="true")){
					$v_value = $v_default_value;
				}
				
				if ($v_type=="selectbox"){
					$v_selectbox_option_sql = $formfield_row["selectbox_option_sql"];
					$v_selectbox_id_column = $formfield_row["selectbox_option_id_column"];
					$v_selectbox_name_column = $formfield_row["selectbox_option_name_column"];
					$v_the_first_of_id_value = $formfield_row["the_first_of_id_value"];
					$v_selectbox_option_sql = str_replace('#OWNER_CODE#' ,$_ISA_OWNER_CODE,$v_selectbox_option_sql);
				}
				if ($v_type=="multiplecheckbox"){
					$v_checkbox_multiple_sql = $formfield_row["checkbox_multiple_sql"];
					$v_checkbox_multiple_id_column = $formfield_row["checkbox_multiple_id_column"];
					$v_checkbox_multiple_name_column = $formfield_row["checkbox_multiple_name_column"];
					$v_checkbox_multiple_sql = str_replace('#OWNER_CODE#' ,$_ISA_OWNER_CODE,$v_checkbox_multiple_sql);									
				}
				if ($v_type=="multipletextbox"){
					$v_first_width = $formfield_row["first_width"];
					$v_textbox_multiple_sql = $formfield_row["textbox_multiple_sql"];
					$v_textbox_multiple_id_column = $formfield_row["textbox_multiple_id_column"];
					$v_textbox_multiple_name_column = $formfield_row["textbox_multiple_name_column"];
					$v_textbox_multiple_sql = str_replace('#OWNER_CODE#' ,$_ISA_OWNER_CODE,$v_textbox_multiple_sql);				
				}
				if ($v_type=="textboxorder"){
					$v_table_name = $formfield_row["table_name"];
					$v_order_column = $formfield_row["order_column"];
					$v_where_clause = $formfield_row["where_clause"];
					$v_textbox_multiple_sql = str_replace('#OWNER_CODE#' ,$_ISA_OWNER_CODE,$v_textbox_multiple_sql);				
				}
				if ($v_type=="fileserver"){
					$v_directory = $formfield_row["directory"];
					$v_file_type = $formfield_row["file_type"];
				}
				$v_html_table = $v_html_table . "<col width='$v_first_col_width'>" . "<col width='$v_second_col_width'>";		
				$v_html_tag = $v_html_tag . _generate_html_input();		
			}
			
			$v_html_str = $v_html_str .  $v_html_table . "<tr id = '$v_row_id' style='display:block'>" . "<td class='normal_label'>" . $v_html_tag."</td>";
			
		$v_count ++;
		}while ($v_count<$v_repeat);
		$v_html_str = $v_html_str . "</tr></table>";
		
		$rec = $rax->readRecord();
	}
	return $v_html_str;
}

// $p_xml_file: duong dan toi file XML mo ta cac form field
// $p_xml_tag: ten THE XML xac dinh NHANH mo ta cac COT trong danh sach 
// $p_arr_all_item: array chua du lieu cua tat ca cac doi tuong
// $p_colume_name_of_xml_string: Ten COT chua chuoi XML
// $p_have_move: Cho phep hien thi mui ten len xuong
// Vi du: _XML_generate_list($v_xml_file, 'col', $arr_all_list, "C_XML_DATA");

function _XML_generate_list($p_xml_file, $p_xml_tag, $p_arr_all_item, $p_colume_name_of_xml_string,$p_have_move=false){
	global $v_value,$v_value_id,$v_url,$v_align,$v_inc,$v_selectbox_option_sql,$v_php_function,$row_index,$v_count,$v_current_style_name,$v_id_column;
	global $v_onclick_up,$v_onclick_down,$v_have_move;
	global $v_readonly_in_edit_mode,$v_disabled_in_edit_mode,$v_selectbox_option_sql,$v_selectbox_id_column,$v_selectbox_name_column;
	$v_have_move = $p_have_move;
	$v_xml_string_in_file = _read_file($p_xml_file);
	$v_count = sizeof($p_arr_all_item);

	//Bang chua cac thanh phan cua form
	$v_html_string = '';

	$rax = new RAX(); 
	$rec = new RAX(); 
	$rax->open($v_xml_string_in_file);
	$rax->record_delim = $p_xml_tag;
	$rax->parse();
	$rec = $rax->readRecord(); 
	$v_html_string = $v_html_string  . '<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">';
	$v_html_temp_width = '';
	$v_html_temp_label = '';
	$v_column = 0;
	while ($rec) { 
		$table_struct_row = $rec->getRow();
		$v_label = $table_struct_row["label"];
		$v_width = $table_struct_row["width"];
		$v_html_temp_width = $v_html_temp_width  . '<col width="'.$v_width .'">';
		$v_html_temp_label = $v_html_temp_label . '<td align="center">'.$v_label.'</td>';
		$rec = $rax->readRecord();
		$v_column ++;
	}
	$v_html_string = $v_html_string  . $v_html_temp_width;
	$v_html_string = $v_html_string  . '<tr class="header">';
	$v_html_string = $v_html_string  . $v_html_temp_label;
	$v_html_string = $v_html_string  . '</tr></table>';
	$v_html_string = $v_html_string  . '<div style="overflow: auto; width: 100%; height:'.(_CONST_HEIGHT_OF_LIST+5).';padding-left:0px;margin:0px">';
	$v_html_string = $v_html_string  . '<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">';
	$v_html_string = $v_html_string  . $v_html_temp_width;
	if ($v_count >0){
		for($row_index = 0; $row_index<$v_count; $row_index++){
			$v_url = "";
			$v_str_xml_data = $p_arr_all_item[$row_index][$p_colume_name_of_xml_string];
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}
			$v_html_string = $v_html_string  .'<tr class="'.$v_current_style_name.'" >'; 
			$rax = new RAX(); 
			$rec = new RAX(); 
			$rax->open($v_xml_string_in_file);
			$rax->record_delim = $p_xml_tag;
			$rax->parse();		
			$rec = $rax->readRecord(); 
			while ($rec) { 
				$table_struct_row = $rec->getRow();
				$v_type = $table_struct_row["type"];
				$v_width = $table_struct_row["width"];
				$v_align = $table_struct_row["align"];
				$v_xml_data = $table_struct_row["xml_data"];
				$v_column_name = $table_struct_row["column_name"];
				$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db"];
				$v_php_function = $table_struct_row["php_function"];
				$v_id_column = $table_struct_row["id_column"];
				$v_selectbox_option_sql = $table_struct_row["selectbox_option_sql"];
				$v_readonly_in_edit_mode = $table_struct_row["readonly_in_edit_mode"];
				$v_disabled_in_edit_mode = $table_struct_row["disabled_in_edit_mode"];
				//Kiem tra neu ma form them moi thi cho phep nhap du lieu
				if (is_null($p_arr_item_value) || sizeof($p_arr_item_value)==0){
					$v_readonly_in_edit_mode = "false";
					$v_disabled_in_edit_mode = "false";
				}
				if ($v_type=="selectbox"){
					$v_selectbox_option_sql = $table_struct_row["selectbox_option_sql"];
					$v_selectbox_id_column = $table_struct_row["selectbox_option_id_column"];
					$v_selectbox_name_column = $table_struct_row["selectbox_option_name_column"];
				}

				
				$arr_xml_tag_in_db = explode(".",$v_xml_tag_in_db);
				if (sizeof($arr_xml_tag_in_db)>1){ //Kiem tra xem the xml can lay co chi ra lay tu cot nao hay khong?
					$v_str_xml_data = $p_arr_all_item[$row_index][$arr_xml_tag_in_db[0]];
					if (is_null($v_str_xml_data)||$v_str_xml_data==""){
						$v_str_xml_data = '<?xml version="1.0" encoding="UTF-8"?><root><data_list></data_list></root>';
					}
					$v_xml_tag_in_db = $arr_xml_tag_in_db[1];
				}		
				if ($v_xml_data=="true"){
					$column_rax = new RAX(); 
					$column_rec = new RAX();
					$column_rax->open($v_str_xml_data);
					$column_rax->record_delim = 'data_list';
					$column_rax->parse();
					$column_rec = $column_rax->readRecord(); 
					$column_row = $column_rec->getRow();
					$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);
					if ($v_value =="") $v_value =" ";
					$v_html_string = $v_html_string  . _generate_html_for_column($v_type); 
				}else{
					$v_value = _replace_bad_char($p_arr_all_item[$row_index][$v_column_name]);
					if ($v_id_column=="true"){
						$v_value_id = $p_arr_all_item[$row_index][$v_column_name];
						$v_url ="item_onclick('" . $v_value_id . "')";
						$v_onclick_up = "btn_move_updown(".$v_value_id . ",'UP')";
						$v_onclick_down = "btn_move_updown(".$v_value_id  . ",'DOWN')";
					}
					if ($v_value =="") {$v_value =" ";}
					$v_html_string = $v_html_string ._generate_html_for_column($v_type); 
				}
				$rec = $rax->readRecord();
			}
			$v_html_string = $v_html_string .'</tr>';
		}
	}
	if ($v_current_style_name == "odd_row"){
		$v_next_style_name = "round_row";
	}else{
		$v_next_style_name = "odd_row";
	}
	$v_html_string = $v_html_string  . _add_empty_row($v_count,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,$v_column);
	$v_html_string = $v_html_string  .'</table></div>';
	return $v_html_string;
}

// Tao chuoi HTML de dinh nghia 1 danh sach cac checkbox
function _generate_html_for_multiple_checkbox($arr_list,$IdColumn,$NameColumn,$Valuelist) {
	global $v_xml_tag_in_db,$v_label,$v_tooltip, $v_formfiel_name;
	global $v_readonly_in_edit_mode,$v_disabled_in_edit_mode;
	$arr_value = explode(",", $Valuelist);
	$v_count_item = sizeof($arr_list);
	$v_count_value = sizeof($arr_value);
	$v_tr_name = '"tr_'.$v_xml_tag_in_db.'"';
	$v_radio_name = '"rad_'.$v_xml_tag_in_db.'"';
	$strHTML = "<DIV title='$v_tooltip' STYLE='overflow: auto; height:105pt;padding-left:5px;margin:0px'>";
	$strHTML = $strHTML . "<table class='list_table2'  width='100%' cellpadding='0' cellspacing='0'><col width='2%'><col width='98%'>";
	if ($v_count_item > 0){
		$i=0;
		$v_item_url_onclick = "_change_item_checked(this,$v_tr_name,$v_radio_name)";
		while ($i<$v_count_item) {
			$v_item_id = $arr_list[$i][$IdColumn];
			$v_item_name = $arr_list[$i][$NameColumn]; 
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}
			$v_item_checked = "";
			$v_item_display = "block";
			if ($Valuelist!=""){ //Kiem tra xem Hieu chinh hay la them moi
				$v_item_display = "none";
			}
			for ($j=0; $j<$v_count_value; $j++)
			if ($arr_value[$j]==$v_item_id){
				$v_item_checked = "checked";
				$v_item_display = "block";
				break;
			}
			$strHTML = $strHTML . "<tr id=$v_tr_name  value='$v_item_id' checked='$v_item_checked' class='$v_current_style_name' style='display:$v_item_display'>";
			$strHTML = $strHTML . "<td><input id='chk_multiple_checkbox' type='checkbox' name='$v_formfiel_name$i' value='$v_item_id' xml_tag_in_db_name ='$v_xml_tag_in_db' $v_item_checked  "._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)."  onClick='$v_item_url_onclick' onKeyDown='change_focus(document.forms(0),this)'></td>";
			$strHTML = $strHTML . "<td style='width:100%'>$v_item_name</td></tr>";
			$i++;
		}
	}
	if ($Valuelist!=""){   //Kiem tra xem Hieu chinh hay la them moi
		$v_checked_show_row_all = "";
		$v_checked_show_row_selected = "checked";
	}else{
		$v_checked_show_row_all = "checked";
		$v_checked_show_row_selected = "";
	}
	if ($v_label==""){
		$v_label = "&#273;&#7889;i t&#432;&#7907;ng";
	}else{
		$v_label = _first_stringtolower($v_label);
	}
	$strHTML = $strHTML ."</table>";
	$strHTML = $strHTML . "</DIV>";
	$strHTML = $strHTML . "<table width='100%' cellpadding='0' cellspacing='0'><col width='2%'><col width='98%'>";
	$strHTML = $strHTML . "<tr><td class='small_radiobutton' colspan='10' align='right'>";
	$strHTML = $strHTML . "<input type='radio' name='rad_$v_formfiel_name' value='1' hide='true' $v_checked_show_row_all "._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." onClick='_show_row_all($v_radio_name,$v_tr_name)' onKeyDown='change_focus(document.forms(0),this)'>Hi&#7875;n th&#7883; t&#7845;t c&#7843; $v_label";
	$strHTML = $strHTML . "<input type='radio' name='rad_$v_formfiel_name' value='2' hide='true' $v_checked_show_row_selected "._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." onClick='_show_row_selected($v_radio_name,$v_tr_name)' onKeyDown='change_focus(document.forms(0),this)'>Ch&#7881; hi&#7875;n th&#7883; c&#225;c $v_label &#273;&#432;&#7907;c ch&#7885;n";
	$strHTML = $strHTML . "</td></tr>";
	$strHTML = $strHTML ."</table>";
	return $strHTML;
}

// Tao chuoi HTML de dinh nghia 1 danh sach cac checkbox
function _generate_html_for_tree_user($p_valuelist) {
	global $v_xml_tag_in_db,$v_label,$v_tooltip;
	global $v_readonly_in_edit_mode,$v_disabled_in_edit_mode;
	$arr_all_cooperator = explode(",", $p_valuelist);
	$v_cooperator_count = sizeof($arr_all_cooperator);
	if (trim($p_valuelist)!=""){
		$strHTML = '<table class="list_table2" width="100%%" cellpadding="0" cellspacing="0">';
		$strHTML = $strHTML .'<col width="6%"><col width="27%"><col width="27%"><col width="36%"><col width="4%">';
		$strHTML = $strHTML .'<tr  class="header">';
		$strHTML = $strHTML .'<td align="center">STT</td>';	
		$strHTML = $strHTML .'<td align="center">H&#7885; t&#234;n</td>';
		$strHTML = $strHTML .'<td align="center">Ch&#7913;c v&#7909</td>';
		$strHTML = $strHTML .'<td align="center">Ph&#242;ng ban</td>';
		$strHTML = $strHTML .'</tr>';
		$strHTML = $strHTML .'</table>';
		$strHTML = $strHTML ."<DIV title='$v_tooltip' STYLE='overflow: auto; height:100pt;padding-left:0px;margin:0px'>";
		$strHTML = $strHTML .'<table class="list_table2" width="100%" cellpadding="0" cellspacing="0" >';
		$strHTML = $strHTML .'<col width="7%"><col width="28%"><col width="28%"><col width="37%">';	
			for($j = 0; $j < $v_cooperator_count; $j++){
				$v_cooperator_id = $arr_all_cooperator[$j];
				$v_cooperator_name = _get_item_attr_by_id($_SESSION['arr_all_staff'],$v_cooperator_id, 'name');
				$v_cooperator_position_name = _get_item_attr_by_id($_SESSION['arr_all_staff'],$v_cooperator_id, 'position_name');
				$v_cooperator_unit_id = _get_item_attr_by_id($_SESSION['arr_all_staff'],$v_cooperator_id, 'unit_id');
				$v_cooperator_unit_name = _get_item_attr_by_id($_SESSION['arr_all_unit'],$v_cooperator_unit_id, 'name');
				if ($v_current_style_name == "odd_row"){
					$v_current_style_name = "round_row";
				}else{
					$v_current_style_name = "odd_row";
				}
				$strHTML = $strHTML .'<tr class="'.$v_current_style_name.'">';
				$strHTML = $strHTML .'<td align="center">'.($j+1).'</td>';
				$strHTML = $strHTML .'<td align="left">'.$v_cooperator_name.'&nbsp;</td>';
				$strHTML = $strHTML .'<td align="left">'.$v_cooperator_position_name.'&nbsp;</td>';
				$strHTML = $strHTML .'<td align="left">'.$v_cooperator_unit_name.'&nbsp;</td>';								
				$strHTML = $strHTML .'</tr>';
			}
		$strHTML = $strHTML .'</table>';
		$strHTML = $strHTML .'</DIV>';
	}
	if (trim($p_valuelist)=="" && $v_disabled_in_edit_mode!="true" && $v_disabled_in_edit_mode !="true"){
		//$strHTML = $strHTML .'<DIV STYLE="overflow: auto; height:100pt; padding-left:0px;margin:0px">';
		$strHTML = $strHTML . "<table class='list_table2'  width='100%' cellpadding='0' cellspacing='0'><col width='2%'><col width='98%'>";
		$strHTML = $strHTML . '<input type="hidden" name="hdn_item_id" value="">';
		$v_item_unit_id = _get_root_unit_id();
		$arr_unit = _get_arr_child_unit($v_item_unit_id);
		$arr_staff = _get_arr_child_staff($arr_unit);
		$arr_list = _attach_two_array($arr_unit,$arr_staff, 5);
		//var_dump($arr_list);
		$v_current_id = 0;
		$xslt=new Xslt();
		$xslt->setXmlString(_built_XML_tree($arr_list,$v_current_id,'true','home.jpg','home.jpg','user.bmp','false'));
		$xslt->setXsl("treeview.xsl");
		if($xslt->transform()) {
			$ret=$xslt->getOutput();
			//echo $ret;
			$strHTML = $strHTML . "<tr><td>".$ret."</td></tr>";
		}else{
			//print("Error:".$xslt->getError());
			$strHTML = $strHTML . "<tr><td>".$xslt->getError()."</td></tr>";
		}	
		$strHTML = $strHTML ."</table>";
		//$strHTML = $strHTML . "</DIV>";
	}
	return $strHTML;
}

// Tao chuoi HTML de dinh nghia 1 danh sach cac checkbox
function _generate_html_for_multiple_checkbox_from_session($p_session_name, $p_session_id_index,$session_name_index,$p_valuelist) {
	global $v_xml_tag_in_db,$v_label,$v_tooltip, $v_formfiel_name;
	global $v_readonly_in_edit_mode,$v_disabled_in_edit_mode;
	//var_dump($_SESSION[$p_session_name]);
	//$arr_list = $_SESSION[$p_session_name];
	$arr_value = explode(",", $p_valuelist);
	//$v_count_item = sizeof($arr_list);
	$v_count_value = sizeof($arr_value);
	$v_tr_name = '"tr_'.$v_xml_tag_in_db.'"';
	$v_radio_name = '"rad_'.$v_xml_tag_in_db.'"';
	$strHTML = "<DIV title='$v_tooltip' STYLE='overflow: auto; height:105pt;padding-left:5px;margin:0px'>";
	$strHTML = $strHTML . "<table class='list_table2'  width='100%' cellpadding='0' cellspacing='0'><col width='2%'><col width='98%'>";
	$i = 0;
	foreach($_SESSION[$p_session_name] as $arr_list) {
		$v_item_url_onclick = "_change_item_checked(this,$v_tr_name,$v_radio_name)";
		$v_item_id = $arr_list[$p_session_id_index];
		$v_item_name = $arr_list[$session_name_index]; 
		if ($v_current_style_name == "odd_row"){
			$v_current_style_name = "round_row";
		}else{
			$v_current_style_name = "odd_row";
		}
		$v_item_checked = "";
		$v_item_display = "block";
		if ($p_valuelist!=""){ //Kiem tra xem Hieu chinh hay la them moi
			$v_item_display = "none";
		}
		for ($j=0; $j<$v_count_value; $j++)
		if ($arr_value[$j]==$v_item_id){
			$v_item_checked = "checked";
			$v_item_display = "block";
			break;
		}
		$strHTML = $strHTML . "<tr id=$v_tr_name  value='$v_item_id' checked='$v_item_checked' class='$v_current_style_name' style='display:$v_item_display'>";
		$strHTML = $strHTML . "<td><input id='chk_multiple_checkbox' type='checkbox' name='$v_formfiel_name$i' value='$v_item_id' xml_tag_in_db_name ='$v_xml_tag_in_db' $v_item_checked "._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." onClick='$v_item_url_onclick' onKeyDown='change_focus(document.forms(0),this)'></td>";
		$strHTML = $strHTML . "<td style='width:100%'>$v_item_name</td></tr>";
		$i++;
	}
	if ($p_valuelist!=""){   //Kiem tra xem Hieu chinh hay la them moi
		$v_checked_show_row_all = "";
		$v_checked_show_row_selected = "checked";
	}else{
		$v_checked_show_row_all = "checked";
		$v_checked_show_row_selected = "";
	}
	if ($v_label==""){
		$v_label = "&#273;&#7889;i t&#432;&#7907;ng";
	}else{
		$v_label = _first_stringtolower($v_label);
	}
	$strHTML = $strHTML ."</table>";
	$strHTML = $strHTML . "</DIV>";
	$strHTML = $strHTML . "<table width='100%' cellpadding='0' cellspacing='0'><col width='2%'><col width='98%'>";
	$strHTML = $strHTML . "<tr><td class='small_radiobutton' colspan='10' align='right'>";
	$strHTML = $strHTML . "<input type='radio' name='rad_$v_formfiel_name' value='1' hide='true' $v_checked_show_row_all "._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." onClick='_show_row_all($v_radio_name,$v_tr_name)' onKeyDown='change_focus(document.forms(0),this)'>Hi&#7875;n th&#7883; t&#7845;t c&#7843; $v_label";
	$strHTML = $strHTML . "<input type='radio' name='rad_$v_formfiel_name' value='2' hide='true' $v_checked_show_row_selected "._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." onClick='_show_row_selected($v_radio_name,$v_tr_name)' onKeyDown='change_focus(document.forms(0),this)'>Ch&#7881; hi&#7875;n th&#7883; c&#225;c $v_label &#273;&#432;&#7907;c ch&#7885;n";
	$strHTML = $strHTML . "</td></tr>";
	$strHTML = $strHTML ."</table>";
	return $strHTML;
}

// Tao chuoi HTML de dinh nghia 1 danh sach cac textbox
function _generate_html_for_multiple_textbox($p_arr_list,$p_index_of_id_column,$p_index_of_name_column,$p_value_list) {
	global $v_xml_tag_in_db,$v_label,$v_tooltip,$v_optional, $v_formfiel_name,$v_dataformat_str,$v_optional_label,$v_message,$v_first_width,$v_width,$v_note;
	global $v_readonly_in_edit_mode,$v_disabled_in_edit_mode;
	//Tach phan ID va phan gia tri
	$arr_of_id_and_value = explode(_CONST_LIST_DELIMITOR._CONST_LIST_DELIMITOR, $p_value_list);
	// Array chua ID
	$arr_id = explode(_CONST_LIST_DELIMITOR, $arr_of_id_and_value[0]);
	// Array chua gia tri
	$arr_value = explode(_CONST_LIST_DELIMITOR, $arr_of_id_and_value[1]);
	//So phan tu cua danh sach 
	$v_count_item = sizeof($p_arr_list);
		//Dem xem co bao nhieu gia tri
	$v_count_value = sizeof($arr_value);
	$v_tr_name = '"tr_'.$v_xml_tag_in_db.'"';
	$v_radio_name = '"rad_'.$v_xml_tag_in_db.'"';
	$v_second_with = (100-$v_first_width);
	$strHTML = "<DIV title='$v_tooltip' STYLE='overflow: auto; height:105pt;padding-left:5px;margin:0px'>";
	$strHTML = $strHTML . "<table class='list_table2'  width='100%' border='0' cellpadding='0' cellspacing='0'>";
	$strHTML = $strHTML . "<col width='$v_first_width%'><col width='$v_second_with%'>";
	if ($v_count_item > 0){
		$i=0;
		//$v_item_url_onclick = "_change_item_checked(this,$v_tr_name,$v_radio_name)";
		while ($i<$v_count_item) {
			$v_item_id = $p_arr_list[$i][$p_index_of_id_column];
			$v_item_name = $p_arr_list[$i][$p_index_of_name_column]; 
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}
			$v_item_checked = "";
			$v_item_display = "block";
			
			for ($j=0; $j<$v_count_value; $j++)
				if ($arr_id[$j]==$v_item_id){
					$v_value = trim($arr_value[$i]);
					break;
			}
			$strHTML = $strHTML . "<tr id=$v_tr_name  value='$v_item_id' checked='$v_item_checked' class='$v_current_style_name' style='display:$v_item_display'>";
			$strHTML = $strHTML . "<td style='display:none'><input id='chk_multiple_textbox' type='checkbox' hide='true' name='chk_multiple_textbox' checked value='$v_item_id' xml_tag_in_db_name ='$v_xml_tag_in_db' "._generate_property_type("optional",$v_optional)." $v_item_checked  onClick='$v_item_url_onclick' onKeyDown='change_focus(document.forms(0),this)'></td>";
			$strHTML = $strHTML . "<td class='normal_label'>$v_item_name"."$v_optional_label</td>";
			$strHTML = $strHTML . "<td class='normal_label'><input id='txt_multiple_textbox' type='textbox' name='$v_formfiel_name$i' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." style='width:$v_width%' value='$v_value' xml_tag_in_db_name ='$v_xml_tag_in_db' $v_dataformat_str message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>$v_note</td>";
			$i++;
		}
	}
	$strHTML = $strHTML ."</table>";
	$strHTML = $strHTML . "</DIV>";
	//$strHTML = $strHTML . "<table width='100%' cellpadding='0' cellspacing='0'><col width='2%'><col width='98%'>";
	//$strHTML = $strHTML . "<tr><td class='small_radiobutton' colspan='10' align='right'>";
	//$strHTML = $strHTML . "<input type='radio' id=$v_radio_name value='1' $v_checked_show_row_all onClick='_show_row_all($v_radio_name,$v_tr_name)' onKeyDown='change_focus(document.forms(0),this)'>Hi&#7875;n th&#7883; t&#7845;t c&#7843; $v_label";
	//$strHTML = $strHTML . "<input type='radio' id=$v_radio_name value='2' $v_checked_show_row_selected onClick='_show_row_selected($v_radio_name,$v_tr_name)' onKeyDown='change_focus(document.forms(0),this)'>Ch&#7881; hi&#7875;n th&#7883; c&#225;c $v_label &#273;&#432;&#7907;c ch&#7885;n";
	//$strHTML = $strHTML . "</td></tr>";
	//$strHTML = $strHTML ."</table>";
	return $strHTML;
}

// Tao chuoi HTML cho cac form field
function _generate_html_input(){
	global $_ISA_IMAGE_URL_PATH,$_ISA_LIB_URL_PATH,$_ISA_WEB_SITE_PATH;
	global $v_label, $v_type, $v_dataformat,$v_message,$v_optional,$v_xml_data,$v_column_name,$v_xml_tag_in_db,$v_readonly_in_edit_mode,$v_disabled_in_edit_mode,$v_note,$v_relate_recordtype,$v_width,$v_first_width,$v_row, $v_row_id, $v_max, $v_min, $v_maxlength,$v_tooltip,$v_listtype_filter,$v_list_id;
	global $v_selectbox_option_sql,$v_selectbox_id_column, $v_selectbox_name_column,$v_function_value;
	global $v_checkbox_multiple_sql,$v_checkbox_multiple_id_column,$v_checkbox_multiple_name_column ,$v_the_first_of_id_value ;
	global $v_textbox_multiple_sql,$v_textbox_multiple_id_column,$v_textbox_multiple_name_column ;
	global $v_table_name, $v_order_column,$v_where_clause; //Cac bien textorder
	global $v_js_function_list,	$v_js_action_list,$v_dataformat_str,$v_optional_label,$v_formfiel_name;
	global $v_directory,$v_file_type;
	global $v_value,$i,$v_row,$v_row_id, $v_counter_file_attack;
	global $v_js_function_after_select,$v_path_root_to_modul;
	global $v_input_data,$v_session_name, $v_session_id_index,$v_session_name_index,$v_session_value_index;
	//Sinh ra cac thuoc tinh dung cho viec kiem hop du lieu tren form
	$v_dataformat_str = _generate_verify_property($v_dataformat);
	$v_url_path_calendar = '"'.$_ISA_LIB_URL_PATH.'isa-calendar/"';
	$v_optional_label = "";
	if ($v_optional=="false"){
		$v_optional_label = "<small class='normal_starmark'>*</small>";
	}
	if ($i==0){
		$v_str_label = $v_label.$v_optional_label."&nbsp;&nbsp;</td><td class='normal_label'>";
	}else{
		$v_str_label = "&nbsp;&nbsp;".$v_label.$v_optional_label."&nbsp;&nbsp;";
	}
	$v_checked = "";

	if ($v_xml_data=='true'){
		$v_formfiel_name = $v_xml_tag_in_db;
	}else{
		$v_formfiel_name = $v_column_name;
	}
	
	switch($v_type) {
		case "label";
			$v_ret_html = $v_label.$v_optional_label."&nbsp;&nbsp;";
			break;	
		case "relaterecord";
			$v_ret_html = $v_str_label;
			$v_ret_html = $v_ret_html . "<input type='textbox' name='$v_formfiel_name' class='normal_textbox' value='$v_value' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>&nbsp;";
			$v_ret_html = $v_ret_html . "<input type='hidden' name='hdn_relate_record_code' value=''>";
			if ($v_value == ""){
				$v_ret_html = $v_ret_html . "<input type='button' name='btn_submit' style='width:auto' title='$v_tooltip' value='L&#7845;y th&#244;ng tin t&#7915; h&#7891; s&#417; li&#234;n quan' class='small_button' onClick='show_modal_dialog_all_record_onclick(&quot;".$_ISA_WEB_SITE_PATH."record/archives/index.php&quot;,&quot;DISPLAY_ALL_RECORD_ARCHIVES&quot;,&quot;$v_relate_recordtype&quot;,document.forms(0).$v_formfiel_name,document.forms(0).hdn_relate_record_code,&quot;DISPLAY_SINGLE_PROJECT&quot;);'>";
			}else{
				$arr_single_record_by_code = _adodb_query_data_in_name_mode("Onegate_RecordGetSingleByCode '$v_value'");
				$v_record_id = $arr_single_record_by_code[0]['PK_RECORD'];
				$v_recordtype = $arr_single_record_by_code[0]['FK_RECORDTYPE'];
				if ($v_record_id>0){
					$v_ret_html = $v_ret_html . "<a href='".$_ISA_WEB_SITE_PATH."record/archives/index.php?fuseaction=DISPLAY_SINGLE_LICENSE&hdn_recordtype_filter=$v_recordtype&hdn_record_id=$v_record_id'>N&#7897;i dung c&#7911;a h&#7891; s&#417; li&#234;n quan</a>";
				}
			}
			break;
		case "fileclient";
			$v_file_attack_name= "txt_xml_file_name". $v_counter_file_attack;
			$v_ret_html = $v_str_label;
			$v_ret_html = $v_ret_html ."<input type='text' name='$v_formfiel_name' style='display:none' class='normal_textbox' title='$v_tooltip' value='$v_value'  style='width:$v_width' style='border=0' readonly  $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode).">";
			$v_ret_html = $v_ret_html ."<input type='file' name='$v_file_attack_name' value='$v_value' class='normal_textbox' title='$v_tooltip' style='width:$v_width' onKeyDown='change_focus(document.forms(0),this)' OnChange='GetFileName(this,document.forms(0).".$v_formfiel_name.")'>";
			$v_ret_html = $v_ret_html . "";
			$v_ret_html = $v_ret_html . $v_note;
			$v_counter_file_attack= $v_counter_file_attack +1;
			break;	
		case "fileserver";
			$v_ret_html = $v_str_label;
			$v_ret_html = $v_ret_html . "<input type='textbox' name='$v_xml_tag_in_db' class='normal_textbox' value='$v_value' title='$v_tooltip' style='width:$v_width' xml_data='$v_xml_data' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' message='$v_message' onKeyDown='change_focus(document.forms(0),this)' readonly>&nbsp;&nbsp;";
			$v_ret_html = $v_ret_html . "<input type='button' name='btn_choose' class='small_button' value='Ch&#7885;n' OnClick='_btn_show_all_file(&quot;$v_directory&quot;,&quot;$v_file_type&quot;,document.all.$v_xml_tag_in_db)' onKeyDown='change_focus(document.forms(0),this)'>"; 
			$v_ret_html = $v_ret_html . $v_note;
			break;		
		case "textbox";
			$v_ret_html = $v_str_label;
			if ($v_dataformat == "isdate"){
				$v_ret_html = $v_ret_html . "<input type='textbox' name='$v_formfiel_name' class='normal_textbox' value='$v_value' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
				$v_ret_html = $v_ret_html . "<img src='". $_ISA_IMAGE_URL_PATH."calendar.gif' border='0' title='$v_tooltip' onclick='DoCal($v_url_path_calendar,document.forms(0).$v_formfiel_name);' style='cursor:hand'>";
			}elseif($v_dataformat == "isuser"){
				if ($v_path_root_to_modul!=""){
					$v_path_root_to_modul = $v_path_root_to_modul."/";
				}
				$v_ret_html = $v_ret_html . "<input type='hidden' name='code_$v_formfiel_name'><input type='hidden' name='$v_formfiel_name' value='$v_value' hide='true' readonly "._generate_property_type("optional",$v_optional)." xml_data='true' xml_tag_in_db='$v_xml_tag_in_db' message='$v_message'>";
				$v_ret_html = $v_ret_html . "<input type='textbox' name='name_$v_formfiel_name' class='normal_textbox' value='"._get_item_attr_by_id($_SESSION['arr_all_staff'],$v_value,'name')."' readonly title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
				if ($v_readonly_in_edit_mode=="false"){
					$v_ret_html = $v_ret_html . "<img border='0' src='".$_ISA_IMAGE_URL_PATH."find.gif' width='18' height='18' title='$v_tooltip' class='normal_image' onClick='show_modal_dialog_treeview_onclick(&quot;".$_ISA_WEB_SITE_PATH.$v_path_root_to_modul."index.php&quot;,&quot;DISPLAY_ALL_STAFF_BY_UNIT&quot;,document.forms(0).name_$v_formfiel_name,document.forms(0).code_$v_formfiel_name,document.forms(0).$v_formfiel_name,-1);$v_js_function_after_select'>";
				}
			}else{
				$v_ret_html = $v_ret_html . "<input type='textbox' name='$v_formfiel_name' class='normal_textbox' value='$v_value' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
				$v_ret_html = $v_ret_html . "";
			}
			$v_ret_html = $v_ret_html . $v_note;
			break;
		case "checkbox";
			if ((is_string($v_value) && $v_value == "true")||(!is_string($v_value) && $v_value)){
				$v_checked = " checked ";
			}
			$v_ret_html = "&nbsp;&nbsp;</td><td class='normal_label'>";
			$v_ret_html = $v_ret_html ."<input type='checkbox' name='$v_formfiel_name' class='normal_checkbox' title='$v_tooltip' $v_checked value='' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
			$v_ret_html = $v_ret_html . "" . $v_label .$v_optional_label."";
			break;
		case "radio";
			if ((is_string($v_value) && $v_value == "true")||(!is_string($v_value) && $v_value)){
				$v_checked = " checked ";
			}
			$v_ret_html =  "<input type='radio' name='$v_row_id' class='normal_checkbox' $v_checked value='' title='$v_tooltip' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
			$v_ret_html = $v_ret_html . "" . $v_label .$v_optional_label."";
			break;
		case "textarea";
			$v_ret_html = $v_str_label;
			$v_ret_html = $v_ret_html . "<textarea class='normal_textarea' name='$v_formfiel_name' rows='$v_row' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message'>$v_value</textarea>";
			break;
		case "selectbox";
			$v_ret_html = $v_str_label;
			$v_array_sql = _adodb_query_data_in_number_mode($v_selectbox_option_sql);
			if ( $v_the_first_of_id_value =="true" && $v_value == "" ){
				$v_array_sql = _adodb_query_data_in_number_mode($v_selectbox_option_sql);
				$v_value = $v_array_sql[0][$v_selectbox_id_column];
			}
			if ($v_input_data != "session"){
				$v_ret_html = $v_ret_html . "<select class='normal_selectbox' name='$v_formfiel_name' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)' >";
				$v_ret_html = $v_ret_html . "<option id='' value='' name='--- Ch&#7885;n $v_label---'>--- Ch&#7885;n $v_label ---</option>"._generate_select_option(_adodb_query_data_in_number_mode($v_selectbox_option_sql),$v_selectbox_id_column,$v_selectbox_id_column,$v_selectbox_name_column,$v_value);
				$v_ret_html = $v_ret_html . "</select>";
			}else{
				$i = 0;
				$arr_list_item = array();
				if (isset($_SESSION[$v_session_name])){
					foreach($_SESSION[$v_session_name] as $arr_item) {
						$arr_list_item[$i] = $arr_item;
						$i++;
					}
				}
				$v_ret_html = $v_ret_html . "<select class='normal_selectbox' name='$v_formfiel_name' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)' >";
				$v_ret_html = $v_ret_html . "<option id='' value='' name='--- Ch&#7885;n $v_label---'>--- Ch&#7885;n $v_label ---</option>"._generate_select_option($arr_list_item,$v_session_id_index,$v_session_value_index,$v_session_name_index,$v_value);
				$v_ret_html = $v_ret_html . "</select>";
			}
			
			break;
		case "multiplecheckbox";
			$v_ret_html = $v_label.$v_optional_label;
			if ($v_input_data != "session"){
				$v_ret_html = $v_ret_html . "<tr id = '$v_row_id' style='display:block'>";
				$v_ret_html = $v_ret_html . "<td style='display:none'><input type='textbox' name='$v_formfiel_name' value='' hide='true' readonly "._generate_property_type("optional",$v_optional)." xml_data='true' xml_tag_in_db='$v_xml_tag_in_db' message='$v_message'>";
				$v_ret_html = $v_ret_html . "</td><td colspan='10'>"._generate_html_for_multiple_checkbox(_adodb_query_data_in_number_mode($v_checkbox_multiple_sql),$v_checkbox_multiple_id_column,$v_checkbox_multiple_name_column,$v_value);
				$v_ret_html = $v_ret_html . "</td></tr>";
			}else{
				$v_ret_html = $v_ret_html . "<tr id = '$v_row_id' style='display:block'>";
				$v_ret_html = $v_ret_html . "<td style='display:none'><input type='textbox' name='$v_formfiel_name' value='' hide='true' readonly "._generate_property_type("optional",$v_optional)." xml_data='true' xml_tag_in_db='$v_xml_tag_in_db' message='$v_message'>";
				$v_ret_html = $v_ret_html . "</td><td colspan='10'>"._generate_html_for_multiple_checkbox_from_session($v_session_name, $v_session_id_index,$v_session_name_index,$v_value);
				$v_ret_html = $v_ret_html . "</td></tr>";
			}
			break;
		case "multipletextbox";
			$v_ret_html = $v_label;
			$v_ret_html = $v_ret_html . "<tr id = '$v_row_id' style='display:block'>";
			$v_ret_html = $v_ret_html . "<td style='display:none'><input type='textbox' name='$v_formfiel_name' value='' hide='true' readonly "._generate_property_type("optional",$v_optional)." xml_data='true' xml_tag_in_db='$v_xml_tag_in_db' message='$v_message'>";
			$v_ret_html = $v_ret_html . "</td><td colspan='10'>"._generate_html_for_multiple_textbox(_adodb_query_data_in_number_mode($v_textbox_multiple_sql),$v_textbox_multiple_id_column,$v_textbox_multiple_name_column,$v_value);
			$v_ret_html = $v_ret_html . "</td></tr>";
			break;
		case "treeuser";
			$v_ret_html = $v_label;
			$v_ret_html = $v_ret_html . "<tr id = '$v_row_id' style='display:block'>";
			$v_ret_html = $v_ret_html . "<td style='display:none'><input type='textbox' name='tree_user' value='".$v_value."' hide='true' readonly "._generate_property_type("optional",$v_optional)." xml_data='true' xml_tag_in_db='$v_xml_tag_in_db' message='$v_message'>";
			$v_ret_html = $v_ret_html . "</td><td colspan='10'>"._generate_html_for_tree_user($v_value);
			$v_ret_html = $v_ret_html . "</td></tr>";
			break;
		case "textboxorder";
			$v_ret_html = $v_str_label;
			if(is_null($v_value) || $v_value==""){
				$v_value = _get_next_value("T_ISALIB_LIST","C_ORDER","FK_LISTTYPE = ".$v_listtype_filter);
				if(!is_null($v_table_name) && $v_table_name!=""){
					$v_value = _get_next_value($v_table_name,$v_order_column,$v_where_clause);
				}
			}
			$v_ret_html = $v_ret_html . "<input type='textbox' name='$v_formfiel_name' class='normal_textbox' value='$v_value' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
			break;
		case "checkboxstatus";
			if ($v_list_id == 0){
				$v_value= true;
			}	
			if ((is_string($v_value) && $v_value == "true")||(!is_string($v_value) && $v_value)){
				$v_checked = " checked ";
			}
			$v_ret_html = "&nbsp;&nbsp;</td><td class='normal_label'>";
			$v_ret_html = $v_ret_html ."<input type='checkbox' name='$v_formfiel_name' class='normal_checkbox' title='$v_tooltip' $v_checked value='' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name'  message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
			$v_ret_html = $v_ret_html . "" . $v_label .$v_optional_label."";
			break;
		case "button";
			$v_ret_html = $v_ret_html . "&nbsp;&nbsp;<input type='button' name='$v_formfiel_name' class='small_button' value='$v_label' title='$v_tooltip' style='width:$v_width' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." $v_dataformat_str xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
			$v_ret_html = $v_ret_html . $v_note;
			break;	
		case "image";			
			$v_ret_html =$v_label;
			$v_ret_html = "&nbsp;&nbsp;<td class='normal_label'>";
			$v_ret_html = $v_ret_html ."<img src='$v_xml_tag_in_db' name='$v_formfiel_name' class='normal_checkbox' title='$v_tooltip' "._generate_property_type("optional",$v_optional)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message'></td>";			
			break;
		default:
			$v_ret_html = "";
	}	
	return $v_ret_html;
}

//Sinh ra XAU chua thuoc tinh cua doi tuong
function _generate_property_type($v_type, $v_value){
	switch($v_type) {	
		case "optional";
			if ($v_value=="false"){
				$v_ret_html = "";
			}else{
				$v_ret_html = " optional = true ";
			}
			break;
		case "readonly";
			if ($v_value=="false"){
				$v_ret_html = "";
			}else{
				$v_ret_html = " readonly = true ";
			}
			break;
		case "disabled";
			if ($v_value=="false"){
				$v_ret_html = " ";
			}else{
				$v_ret_html = " disabled = true ";
			}
			break;
		default:
			$v_ret_html = "";
	}	
	return $v_ret_html;

}

//Tao chuoi HTML chua ham va cac su kien tuong ung voi ham cua cac doi tuong
function _generate_event_and_function($v_js_function_list, $v_js_action_list){
	$arr_js_function_list = explode(",", $v_js_function_list);
	$arr_js_action_list =   explode(",", $v_js_action_list);
	$v_count_function =     sizeof($arr_js_function_list);
	$v_count_action =       sizeof($arr_js_action_list);
	$v_count = $v_count_function > $v_count_action ? $v_count_action : $v_count_function;
	$v_temp = "";
	for ($i=0;$i<$v_count;$i++){
		$v_temp = $v_temp . " $arr_js_action_list[$i]='$arr_js_function_list[$i]' ";  
	}
	return $v_temp;
}

//Tao chuoi HTML chua thuoc tinh rang buoc du lieu cua cac doi tuong tren from
function _generate_verify_property($v_dataformat){
	switch($v_dataformat) {	
		case "isemail";
			$v_ret_html = " isemail=true " ;
			break;
		case "isdate";
			$v_ret_html = " isdate=true " ;
			break;
		case "isnumeric";
			$v_ret_html = " isnumeric=true " ;
			break;
		case "ismoney";
			$v_ret_html = " isnumeric=true onKeyUp='format_money(this)' ";
			break;
		default:
			$v_ret_html = "";
	}	
	return $v_ret_html;
}
// Tao chuoi HTML cho cac cot cua danh sach
function _generate_html_for_column($p_type){
	global $_ISA_WEB_SITE_PATH;
	global $v_value,$v_value_id,$v_url,$v_align,$v_inc,$v_selectbox_option_sql,$v_php_function,$row_index,$v_count,$v_id_column,$v_onclick_up,$v_onclick_down;
	global $v_have_move;
	global $v_readonly_in_edit_mode,$v_disabled_in_edit_mode,$v_selectbox_option_sql,$v_selectbox_id_column,$v_selectbox_name_column;
	switch($p_type) {	
		case "checkbox";
			$v_ret_html = '<td align="'.$v_align.'"><input type="checkbox" name="chk_item_id" value="'.$v_value.'">&nbsp;<a name="'.$v_value.'">&nbsp;</a>';
			if ($v_id_column =="true" && $v_have_move){
				if ($row_index !=0){
					$v_ret_html = $v_ret_html. '<img src="'.$_ISA_WEB_SITE_PATH.'images/up.gif" border="0" style="cursor:hand;" onClick="'.$v_onclick_up.'">';
				}else{
					$v_ret_html = $v_ret_html. '&nbsp;&nbsp;&nbsp;';
				}
				if ($row_index != $v_count-1){
					$v_ret_html = $v_ret_html. '<img src="'.$_ISA_WEB_SITE_PATH.'images/down.gif" border="0" style="cursor:hand;" onClick="'.$v_onclick_down.'">';
				}else{
					$v_ret_html = $v_ret_html. '&nbsp;&nbsp;&nbsp;&nbsp;';
				}
			}
			$v_ret_html  = $v_ret_html .'</td>';
			break;
		case "selectbox";
			$v_ret_html = $v_str_label;
			$v_ret_html = $v_ret_html . "<td align='.$v_align.'><select class='normal_selectbox' name='sel_item' title='$v_tooltip' style='width:100%' "._generate_property_type("optional",$v_optional)._generate_property_type("readonly",$v_readonly_in_edit_mode)._generate_property_type("disabled",$v_disabled_in_edit_mode)._generate_event_and_function($v_js_function_list, $v_js_action_list)." xml_tag_in_db='$v_xml_tag_in_db' xml_data='$v_xml_data' column_name='$v_column_name' message='$v_message' onKeyDown='change_focus(document.forms(0),this)'>";
			$v_ret_html = $v_ret_html . "<option id='' value=''>--- Ch&#7885;n $v_label ---</option>"._generate_select_option(_adodb_query_data_in_number_mode($v_selectbox_option_sql),$v_selectbox_id_column,$v_selectbox_id_column,$v_selectbox_name_column,$v_value);
			$v_ret_html = $v_ret_html . "</select></td>";
			//$v_ret_html = '<td align="'.$v_align.'" onclick="'.$v_url.'">'._get_value_from_array(_adodb_query_data_in_number_mode($v_selectbox_option_sql),"0","1",$v_value).'&nbsp;</td>';
			break;
		case "textbox";
			$v_ret_html = '<td align="'.$v_align.'"><input type="textbox" name="txt_item_id" value="'.$v_value.'">';
			$v_ret_html  = $v_ret_html .'</td>';
			break;
		case "function";
			$v_ret_html = '<td class="data" align="'.$v_align.'" onclick="'.$v_url.'">'.call_user_func($v_php_function,$v_value).'&nbsp;</td>';
			break;
		case "date";
			$v_ret_html = '<td class="data" align="'.$v_align.'" onclick="'.$v_url.'">'._yyyymmdd_to_ddmmyyyy($v_value).'&nbsp;</td>';
			break;
		case "time";
			$v_ret_html = '<td class="data" align="'.$v_align.'" onclick="'.$v_url.'">'._yyyymmdd_to_hhmmss($v_value).'&nbsp;</td>';
			break;
		case "text";
			$v_ret_html = '<td class="data" align="'.$v_align.'" onclick="'.$v_url.'">'.$v_value.'&nbsp;</td>';
			break;
		case "identity";
			$v_ret_html = '<td class="data" align="'.$v_align.'" onclick="'.$v_url.'">'.$v_inc.'&nbsp;</td>';
			break;
		case "money";
			$v_ret_html = '<td class="data" align="'.$v_align.'" onclick="'.$v_url.'">'._data_format($v_value).'&nbsp;</td>';
			break;
		default:
			$v_ret_html = $v_value;
	}	
	return $v_ret_html;
}
// Dinh dang tien te, so theo dung dinh dang
function _data_format($p_value){
	$v_ret_value = strval($p_value);
	if ($v_ret_value=="" || is_null($v_ret_value)){
		return "";
	}
	$arr_value=explode(".",$v_ret_value);
	if (isset($arr_value[1]) && $arr_value[1]*1==0){
		$v_ret_value = $arr_value[0];
	}
	if (strpos($v_ret_value,".")===false){
		$v_ret_value = number_format($v_ret_value, 0, '.', ',');
	}else{
		$v_ret_value = number_format($v_ret_value, 2, '.', ',');
	}	
	if ($v_ret_value == "0.00") $v_ret_value = "0";
	return $v_ret_value;
}
//Chuyen chu cai dau tien cua xau thanh chu thuong
function _first_stringtolower($p_str){
	$v_temp = substr($p_str,1,strlen($p_str));
	$v_temp = strtolower(substr($p_str,0,1)).$v_temp ;
	return $v_temp;
}

//Lay gia tri cua phan tu co ID:$SelectedValue tu danh sach
//$arr_list : Mang chua danh sach
//$IdColumn : Ten cot chua ID can so sanh
//$NameColumn: Ten cot chua chua gi tri tra ve
//$SelectedValue: Gia tri so sanh voi ID cua danh sach
function _get_value_from_array($arr_list,$IdColumn,$NameColumn,$SelectedValue) {
	$v_value = "";
	$count=sizeof($arr_list);
	for($row_index = 0;$row_index< $count;$row_index++){
		$strID=trim($arr_list[$row_index][$IdColumn]);
		$DspColumn=trim($arr_list[$row_index][$NameColumn]);
		if($strID == $SelectedValue) {
			$v_value = $DspColumn;
		} 
	}
	return $v_value;
}

//Ham so sanh gia tri cua xau  DUNG CHO SAP XEP DU LIEU
function _compare_two_value($a, $b){
	global $v_group_by,$v_xml_data_compare;
	if ($v_xml_data_compare == "true"){
		$v_xml_string_a = $a['C_RECEIVED_RECORD_XML_DATA'];
		$v_xml_string_b = $b['C_RECEIVED_RECORD_XML_DATA'];
		//Lay gia tri tu mang a
		$column_rax = new RAX(); 
		$column_rec = new RAX();
		$column_rax->open($v_xml_string_a);
		$column_rax->record_delim = 'data_list';
		$column_rax->parse();
		$column_rec = $column_rax->readRecord(); 
		$column_row = $column_rec->getRow();
		$v_value_a = _restore_XML_bad_char($column_row[$v_group_by]);
		//Lay gia tri tu mang b
		$column_rax = new RAX(); 
		$column_rec = new RAX();
		$column_rax->open($v_xml_string_b);
		$column_rax->record_delim = 'data_list';
		$column_rax->parse();
		$column_rec = $column_rax->readRecord(); 
		$column_row = $column_rec->getRow();
		$v_value_b = _restore_XML_bad_char($column_row[$v_group_by]);
		return strcmp($v_value_a, $v_value_b);
	}else{
		return strcmp($a[$v_group_by],$b[$v_group_by]); 		
	}
}
//Ham nay co chuc nang in ra phan than cua bao cao

function _XML_generate_report_body($p_xml_file,$p_xml_tag, $p_arr_all_item, $p_colume_name_of_xml_string){
	global $v_value,$v_value_id,$v_url,$v_align,$v_inc,$v_selectbox_option_sql,$v_php_function,$row_index,$v_count,$v_current_style_name,$v_id_column;
	global $v_group_by,$v_xml_data_compare;//Cac tham so de truyen vao ham _compare_two_value
	$v_xml_string_in_file = _read_file($p_xml_file);
	$v_count = sizeof($p_arr_all_item);

	//Bang chua cac phan than cua bao cao
	$v_column = 0;
	$v_html_temp_width = '';
	$v_html_temp_label = '';
	$v_current_style_name = "round_row";
	$v_HTML_string = '';
	//Cac tham so de nhom du lieu
	$v_group_by = _XML_get_xml_tag_value($v_xml_string_in_file,"report_sql","group_by");
	$v_group_name = _XML_get_xml_tag_value($v_xml_string_in_file,"report_sql","group_name");
	$v_xml_data_compare = _XML_get_xml_tag_value($v_xml_string_in_file,"report_sql","xml_data");

	$v_calculate_total = _XML_get_xml_tag_value($v_xml_string_in_file,"report_sql","calculate_total");
	
	//Lay ten file HTML dinh dang tieu de cot bao cao
	$v_report_label_file = trim(_XML_get_xml_tag_value($v_xml_string_in_file,"report_header","table_header_file"));
	if ($v_report_label_file != ""){
		//Tieu de cot doc tu file HTML vao
		$v_report_label_file = CONST_REPORT_LABEL_FILE_URL_PATH.$v_report_label_file;	
		$v_html_label_content = _read_file($v_report_label_file);	
		$v_HTML_string = $v_HTML_string.$v_html_label_content;
	}
	
	$table_struct_rax = new RAX(); 
	$table_struct_rec = new RAX(); 
	$table_struct_rax->open($v_xml_string_in_file);
	$table_struct_rax->record_delim = $p_xml_tag;
	$table_struct_rax->parse();
	$table_struct_rec = $table_struct_rax->readRecord(); 
	while ($table_struct_rec) { 
		$table_struct_row = $table_struct_rec->getRow();
		$v_type =  $table_struct_row["type"]; 
		$v_label = $table_struct_row["label"]; 
		$v_width = $table_struct_row["width"];
		$v_align = $table_struct_row["align"];
		//Lay danh sach do rong cac cot cua bang
		$v_html_temp_width = $v_html_temp_width  . '<col width="'.$v_width .'">';
		//Lay danh sach cac tieu de cua cot
		$v_html_temp_label = $v_html_temp_label . '<td class="header" align="'.$v_align.'">'.$v_label.'</td>';
		$arr_type[$v_column] = $v_type;
		$arr_align[$v_column] = $v_align;
		$table_struct_rec = $table_struct_rax->readRecord();
		$v_column ++;
	}
	$v_width_col = 100/$v_column;
	$v_html_col_list = $v_html_col_list .str_repeat("<col width:'$v_width_col%'>",$v_column);

	if($v_report_label_file == ""){
		$v_HTML_string = $v_HTML_string  . '<table class="report_table" style="width:100%" border="0" cellpadding="0" cellspacing="0">';
		$v_HTML_string = $v_HTML_string  . $v_html_temp_width;
		//Lay tieu de cot tu file XML
		$v_HTML_string = $v_HTML_string  . '<tr>';
		$v_HTML_string = $v_HTML_string  . $v_html_temp_label;
		$v_HTML_string = $v_HTML_string  . '</tr>';
	}
	//Khoi tao thu tu cua danh sach va nhom 
	$group_index=1;
	$v_inc = 1;
	if ($v_count >0){
		//Vong lap hien thi danh sach cac ho so
		$v_old_row = $p_arr_all_item[0];
		for ($i=0; $i< $v_column; $i++){
			$arr_calculate[$i] = 0;
		}
		for($row_index = 0;$row_index <$v_count ;$row_index++){
			$v_recordset = $p_arr_all_item[$row_index];
			$v_received_record_xml_data = $p_arr_all_item[$row_index][$p_colume_name_of_xml_string];
			$v_recordtype_code = $p_arr_all_item[$row_index]['FK_RECORDTYPE'];
			$v_group_name_label = $p_arr_all_item[$row_index][$v_group_name];
			if ($v_current_style_name == "odd_row"){
				$v_current_style_name = "round_row";
			}else{
				$v_current_style_name = "odd_row";
			}
			//Bat dau 1 dong			
			$table_struct_rax = new RAX(); 
			$table_struct_rec = new RAX(); 
			$table_struct_rax->open($v_xml_string_in_file);
			$table_struct_rax->record_delim = $p_xml_tag;
			$table_struct_rax->parse();
			$table_struct_rec = $table_struct_rax->readRecord();
			$v_col_index = 0; 
			$v_HTML_string_row = '';
			//In tieu de cua nhom
			if (trim($v_group_by)!="" && $row_index == 0){	
				$v_HTML_string = $v_HTML_string  .'<tr class="'.$v_current_style_name.'" >';
				$v_HTML_string = $v_HTML_string  .'<td class="data"><B>'.$group_index.'</B></td>';
				$v_HTML_string = $v_HTML_string  .'<td class="data" colspan="'.($v_column-1).'"><B>'.$p_arr_all_item[$row_index][$v_group_name].'</B></td>';
				$v_HTML_string = $v_HTML_string  .'</tr>';
			}
			while ($table_struct_rec) { 
				$table_struct_row = $table_struct_rec->getRow();
				$v_type = $table_struct_row["type"];
				$v_width = $table_struct_row["width"];
				$v_align = $table_struct_row["align"];
				$v_xml_data = $table_struct_row["xml_data"];
				$v_calculate = $table_struct_row["calculate"];
				$v_compare_value = $table_struct_row["compare_value"];
				$v_column_name = $table_struct_row["column_name"];
				$v_xml_tag_in_db_list = $table_struct_row["xml_tag_in_db_list"];
				//Lay the xml chua noi dung can hien thi tu danh sach tuong ung voi ma
				if (_list_get_len($v_xml_tag_in_db_list,',')>1){
					$v_xml_tag_in_db = get_value_from_two_list($v_recordtype_code,$table_struct_row["recordtype_code_list"],$table_struct_row["xml_tag_in_db_list"]);
				}else{
					$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db_list"];
				}
				$v_selectbox_option_sql = $table_struct_row["selectbox_option_sql"];
				$v_php_function = $table_struct_row["php_function"];
				$arr_xml_tag_in_db = explode(".",$v_xml_tag_in_db);
				if (sizeof($arr_xml_tag_in_db)>1){
					$v_received_record_xml_data = $p_arr_all_item[$row_index][$arr_xml_tag_in_db[0]];
					$v_xml_tag_in_db = $arr_xml_tag_in_db[1];
				}else{
					$v_xml_tag_in_db = $table_struct_row["xml_tag_in_db_list"];
				}			
				if ($v_xml_data=="true" && $v_received_record_xml_data!="" && !is_null($v_received_record_xml_data)){
					$column_rax = new RAX(); 
					$column_rec = new RAX();
					$column_rax->open($v_received_record_xml_data);
					$column_rax->record_delim = 'data_list';
					$column_rax->parse();
					$column_rec = $column_rax->readRecord(); 
					$column_row = $column_rec->getRow();
					$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]);					
				}else{
					$v_value = $p_arr_all_item[$row_index][$v_column_name];
				}
				if ($v_type=="money"){
					$v_value = str_replace(",","",$v_value);
				}
				//In tu dong cua bao cao
				$v_HTML_string_row = $v_HTML_string_row . _generate_html_for_column($v_type); 
				//Neu ma tinh so luong
				if ($v_calculate=="count"){
					if ((trim($v_compare_value)!="")&&(_list_have_element(trim($v_compare_value), trim($v_value),","))){
						$arr_calculate[$v_col_index] = $arr_calculate[$v_col_index] + 1;
						$arr_total_calculate[$v_col_index] = $arr_total_calculate[$v_col_index] + 1;
					}
				}elseif ($v_calculate=="sum"){//Neu tinh tong cac gia tri
					$arr_calculate[$v_col_index] = $arr_calculate[$v_col_index] + intval($v_value);
					$arr_total_calculate[$v_col_index] = $arr_total_calculate[$v_col_index] + intval($v_value);
				}else{						
					$arr_calculate[$v_col_index] = "";
					$arr_total_calculate[$v_col_index] = "";
				}
				$v_col_index ++;
				$table_struct_rec = $table_struct_rax->readRecord();
			}//End while
			$v_HTML_string = $v_HTML_string  .'<tr class="'.$v_current_style_name.'" >';
			$v_HTML_string = $v_HTML_string  .$v_HTML_string_row;
			$v_HTML_string = $v_HTML_string  .'</tr>';
			$v_inc ++;
			if (trim($v_group_by)!=""){	
				$v_current_row = $p_arr_all_item[$row_index+1];
				if ((_compare_two_value($v_old_row,$v_current_row)!=0)){
					//Khoi tao lai thu tu cua danh sach		
					$v_inc = 1;
					$group_index++;
					$v_html_temp = "";
					//Hien thi phan tinh toan theo nhom
					for ($i=0;$i < sizeof($arr_calculate);$i++){
						if ($arr_calculate[$i]>=0){
							$v_type = $arr_type[$i];
							$v_align = $arr_align[$i];
							$v_value = $arr_calculate[$i];						
							$arr_calculate[$i] = 0;
							if ($v_type=="money"){
								$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'">'.onegate_data_format($v_value).'&nbsp;</td>';
							}elseif($v_type=="identity"){
								$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'">&nbsp;</td>';
							}elseif($i==1){
								$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'"><B>C&#7897;ng:&nbsp;'.$v_group_name_label.'</B></td>';
							}else{
								$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'">'.$v_value.'&nbsp;</td>';
							}
						}
					}
					$v_HTML_string = $v_HTML_string  .'<tr class="'.$v_current_style_name.'" >';
					$v_HTML_string = $v_HTML_string  .$v_html_temp;
					$v_HTML_string = $v_HTML_string  .'</tr>';
					//In tieu de cua nhom
					if (trim($v_group_by)!="" && $row_index<$v_count-1){	
						$v_HTML_string = $v_HTML_string  .'<tr class="'.$v_current_style_name.'" >';
						$v_HTML_string = $v_HTML_string  .'<td class="data"><B>'.$group_index.'</B></td>';
						$v_HTML_string = $v_HTML_string  .'<td class="data" colspan="'.($v_column-1).'"><B>'.$p_arr_all_item[$row_index+1][$v_group_name].'</B></td>';
						$v_HTML_string = $v_HTML_string  .'</tr>';
					}
					
				}//End if							
				$v_old_row = $v_current_row;
			}							
			//Ket thuc mot dong
		}//End for
	}//End if
	//Hien thi phan tinh toan tong
	if ($v_calculate_total=="true"){
		$v_html_temp = "";
		for ($i=0;$i < sizeof($arr_total_calculate);$i++){
			//if ($arr_total_calculate[$i]>=0){
				$v_type = $arr_type[$i];
				$v_align = $arr_align[$i];
				$v_value = $arr_total_calculate[$i];
				if ($v_type=="money"){
					$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'">'._data_format($v_value).'&nbsp;</td>';
				}elseif($v_type=="identity"){
					$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'">&nbsp;</td>';
				}elseif($i==1){
					$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'"><B>T&#7893;ng c&#7897;ng&nbsp;</B></td>';			
				}else{
					$v_html_temp = $v_html_temp .'<td class="data" align="'.$v_align.'">'.$v_value.'&nbsp;</td>';
				}
			//}
		}
		$v_HTML_string = $v_HTML_string  .'<tr class="'.$v_current_style_name.'" >';
		$v_HTML_string = $v_HTML_string  .$v_html_temp;
		$v_HTML_string = $v_HTML_string  .'</tr>';
	}
	if ($v_current_style_name == "odd_row"){
		$v_next_style_name = "round_row";
	}else{
		$v_next_style_name = "odd_row";
	}
	//Ket thuc ban bang cua bao cao
	$v_HTML_string = $v_HTML_string  .'</table>';
	return $v_HTML_string;
}

//Sinh ra chuoi HTML chua du lieu ve dieu kien loc cua bao cao
function _XML_generate_report_header($p_xml_file,$p_xml_tag_row,$p_xml_tag_col, $p_filter_xml_string){
	global $_ISA_OWNER_NAME;
	global $v_label, $v_type, $v_dataformat,$v_width,$v_row, $v_row_id;
	global $v_selectbox_option_sql,$v_selectbox_id_column, $v_selectbox_name_column;
	global $v_value,$i,$v_row;
	global $v_input_data,$v_session_name, $v_session_id_index,$v_session_name_index,$v_session_value_index;

	$v_xml_string_in_file = _read_file($p_xml_file);
	$v_current_date = "ng&#224;y ". date("d"). " th&#225;ng " . date("m")." n&#259;m " . date("Y");
	$v_column = 0;
	$table_struct_rax = new RAX(); 
	$table_struct_rec = new RAX(); 
	$table_struct_rax->open($v_xml_string_in_file);
	$table_struct_rax->record_delim = $p_xml_tag_col;
	$table_struct_rax->parse();
	$table_struct_rec = $table_struct_rax->readRecord(); 
	while ($table_struct_rec) { 
		$table_struct_row = $table_struct_rec->getRow();
		$table_struct_rec = $table_struct_rax->readRecord();
		$v_column ++;
	}
	$v_width_col = 100/$v_column;
	$v_html_col_list = '';
	$v_html_col_list = $v_html_col_list . str_repeat("<col width:'$v_width_col%'>",$v_column);
	$v_HTML_string = '';
	$v_report_unit = _XML_get_xml_tag_value($v_xml_string_in_file,"report_header","report_unit");
	$v_report_unit_father = _XML_get_xml_tag_value($v_xml_string_in_file,"report_header","report_unit_father");
	$v_report_unit_child = _XML_get_xml_tag_value($v_xml_string_in_file,"report_header","report_unit_child");
	$v_report_date = _XML_get_xml_tag_value($v_xml_string_in_file,"report_header","report_date");
	$v_large_title = _XML_get_xml_tag_value($v_xml_string_in_file,"report_header","large_title");
	$v_report_unit = _XML_get_xml_tag_value($v_xml_string_in_file,"report_header","report_unit");
	
	$v_HTML_string = $v_HTML_string  .'<table width="99%" border="0" cellpadding="0" cellspacing="0">';
	$v_HTML_string = $v_HTML_string  . $v_html_col_list;
	/*
	if(trim($v_report_unit)!='')
		$v_HTML_string = $v_HTML_string  .'<tr valign="top"><td align="center" class="report_unit_name" colspan="'.floor($v_column/2).'">'.$_ISA_OWNER_NAME."<br>".$v_report_unit.'</td>';
	else
		$v_HTML_string = $v_HTML_string  .'<tr valign="top"><td align="center" class="report_unit_name" colspan="'.floor($v_column/2).'">'.CONST_REPORT_HEADER_TOP_LEFT_LABEL."<br>".$_ISA_OWNER_NAME.'</td>';
	*/
	$v_HTML_string = $v_HTML_string  .'<tr valign="top"><td align="center" class="report_unit_name" colspan="'.floor($v_column/2).'">'.$v_report_unit_father."<br>".$v_report_unit_child.'</td>';
	$v_HTML_string = $v_HTML_string  .'<td align="center" class="freedom_republic" colspan="'.($v_column-floor($v_column/2)).'">'._CONST_REPUBLIC_TITLE.'<br>'._CONST_FREEDOM_TITLE.'</td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="normal_label" colspan="'.$v_column.'">&nbsp;</td>';
	//$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="normal_label" colspan="'.$v_column.'">==============***==============</td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="right" class="date" colspan="'.$v_column.'"><i>'.$v_report_date.$v_current_date.'</i></td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="normal_label" colspan="'.$v_column.'">&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="title" colspan="'.$v_column.'">'.$v_large_title.'</td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="sub_title" colspan="'.$v_column.'">'.$v_small_title.'</td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="normal_label" colspan="'.$v_column.'">&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'</tr><tr><td align="center" class="normal_label" colspan="'.$v_column.'">&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'</tr></table>';
	//Het phan tieu de cua bao cao
	//Phan chua cac tieu thuc loc bao cao
	$table_struct_rax = new RAX(); 
	$table_struct_rec = new RAX(); 
	$table_struct_rax->open($v_xml_string_in_file);
	$table_struct_rax->record_delim = $p_xml_tag_row;
	$table_struct_rax->parse();
	$table_struct_rec = $table_struct_rax->readRecord(); 
	while ($table_struct_rec) { 
		$table_struct_row = $table_struct_rec->getRow();
		$v_tag_list = $table_struct_row["tag_list"];
		$v_row_id = $table_struct_row["row_id"];
		$arr_tag = explode(",", $v_tag_list);
		//Bang chua mot dong cua form
		$v_HTML_string = $v_HTML_string . "<table width='99%'  border='0' cellspacing='0' cellpadding='0'>";
		$v_html_table = "";
		$v_html_tag = "";									
		for($i=0;$i < sizeof($arr_tag);$i++){
			$formfield_rax = new RAX(); 
			$formfield_rec = new RAX(); 
			$formfield_rax->open($v_xml_string_in_file);
			$formfield_rax->record_delim = $arr_tag[$i];
			$formfield_rax->parse();
			$formfield_rec = $formfield_rax->readRecord(); 
			$formfield_row = $formfield_rec->getRow(); 
			$v_label = $formfield_row["label"];
			$v_type = $formfield_row["type"];
			$v_dataformat = $formfield_row["data_format"];
			$v_width = $formfield_row["width"];
			$v_row = $formfield_row["row"];
			$v_max = $formfield_row["max"];
			$v_min = $formfield_row["min"];
			$v_maxlength = $formfield_row["maxlength"];
			$v_note = $formfield_row["note"];
			$v_message = $formfield_row["message"];
			$v_optional = $formfield_row["optional"];
			$v_xml_tag_in_db = $formfield_row["xml_tag_in_db"];
			$v_js_function_list = $formfield_row["js_function_list"];
			$v_js_action_list = $formfield_row["js_action_list"];
			$v_readonly_in_edit_mode = $formfield_row["readonly_in_edit_mode"];
			$v_disabled_in_edit_mode = $formfield_row["disabled_in_edit_mode"];
			//lay du lieu tu session
			$v_input_data = $formfield_row["input_data"];
			$v_session_name = $formfield_row["session_name"];
			$v_session_id_index = $formfield_row["session_id_index"];
			$v_session_name_index = $formfield_row["session_name_index"];
			$v_session_value_index = $formfield_row["session_value_index"];
			if ($p_filter_xml_string!=""){
				$column_rax = new RAX(); 
				$column_rec = new RAX();
				$column_rax->open($p_filter_xml_string);
				$column_rax->record_delim = 'data_list';
				$column_rax->parse();
				$column_rec = $column_rax->readRecord(); 
				$column_row = $column_rec->getRow();
				$v_value = _restore_XML_bad_char($column_row[$v_xml_tag_in_db]); 
			}
			if ($v_type=="selectbox"){
				$v_selectbox_option_sql = $formfield_row["selectbox_option_sql"];
				$v_selectbox_id_column = $formfield_row["selectbox_option_id_column"];
				$v_selectbox_name_column = $formfield_row["selectbox_option_name_column"];
			}
			if ($v_type=="checkboxmultiple"){
				$v_checkbox_multiple_sql = $formfield_row["checkbox_multiple_sql"];
				$v_checkbox_multiple_id_column = $formfield_row["checkbox_multiple_id_column"];
				$v_checkbox_multiple_name_column = $formfield_row["checkbox_multiple_name_column"];
			}
			$v_html_table = $v_html_table . "<col width='$v_first_col_width'>" . "<col width='$v_second_col_width'>";		
			$v_html_tag = $v_html_tag . _Generate_HTML_Output();		
		}
		$v_HTML_string = $v_HTML_string .  $v_html_table . "<tr><td class='normal_label' align='center' colspan='$v_column'>" . $v_html_tag."</td></tr>";
		$v_HTML_string = $v_HTML_string . "</table>";
		$table_struct_rec = $table_struct_rax->readRecord();
	}
	$v_HTML_string = $v_HTML_string . "<table width='99%'  border='0' cellspacing='0' cellpadding='0'>";
	$v_HTML_string = $v_HTML_string . "<tr><td colspan='$v_column'>&nbsp;</td></tr>";
	$v_HTML_string = $v_HTML_string . "</table>";
	return $v_HTML_string;
}

function _XML_generate_report_footer($p_xml_file,$p_xml_tag){
	$v_xml_string_in_file = _read_file($p_xml_file);
	$v_column = 0;
	$table_struct_rax = new RAX(); 
	$table_struct_rec = new RAX(); 
	$table_struct_rax->open($v_xml_string_in_file);
	$table_struct_rax->record_delim = $p_xml_tag;
	$table_struct_rax->parse();
	$table_struct_rec = $table_struct_rax->readRecord(); 
	while ($table_struct_rec) { 
		$table_struct_row = $table_struct_rec->getRow();
		$table_struct_rec = $table_struct_rax->readRecord();
		$v_column ++;
	}
	$v_width_col = 100/$v_column;
	$v_html_col_list = '';
	$v_html_col_list = $v_html_col_list .str_repeat("<col width:'$v_width_col%'>",$v_column);
	
	$v_HTML_string = '';
	$v_report_creator = _XML_get_xml_tag_value($v_xml_string_in_file,"report_footer","report_creator");
	$v_report_approver = _XML_get_xml_tag_value($v_xml_string_in_file,"report_footer","report_approver");
	$v_report_signer = _XML_get_xml_tag_value($v_xml_string_in_file,"report_footer","report_signer");
	$v_HTML_string = $v_HTML_string  .'<table width="99%" border="0" cellspacing="0" cellpadding="0">';
	$v_HTML_string = $v_HTML_string  . $v_html_col_list;
	$v_HTML_string = $v_HTML_string  .'<tr><td class="normal_label" colspan="'.$v_column.'">&nbsp;</td></tr><tr>';
	$v_HTML_string = $v_HTML_string  .'<tr><td class="normal_label" colspan="'.$v_column.'">&nbsp;</td></tr><tr>';
	$v_HTML_string = $v_HTML_string  .'<td class="normal_label">&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'<td align="center" class="creator">'.$v_report_creator.'&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'<td align="center" class="approver">'.$v_report_approver.'&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'<td align="center" class="signer">'.$v_report_signer.'&nbsp;</td>';
	$v_HTML_string = $v_HTML_string  .'</tr></table>';
	return $v_HTML_string;
}
function _Generate_HTML_Output(){
	global $v_label, $v_type, $v_dataformat,$v_width,$v_row, $v_row_id;
	global $v_selectbox_option_sql,$v_selectbox_id_column, $v_selectbox_name_column;
	global $v_value,$i,$v_row ;
	global $v_input_data,$v_session_name, $v_session_id_index,$v_session_name_index,$v_session_value_index;
	global $_ISA_OWNER_CODE;
	$v_selectbox_option_sql = str_replace('#OWNER_CODE#' ,$_ISA_OWNER_CODE,$v_selectbox_option_sql);
	$v_optional_label = "";
	$v_str_label = "&nbsp;&nbsp;".$v_label."&nbsp;&nbsp;";
	switch($v_type) {
		case "label";
			$v_ret_html = $v_label.$v_optional_label."&nbsp;&nbsp;";
			break;	
		case "textbox";
			$v_ret_html = $v_str_label;
			$v_ret_html = $v_ret_html . $v_value;
			break;
		case "selectbox";
			$v_ret_html = $v_str_label;
			if ($v_input_data != "session"){
				$v_ret_html = $v_ret_html ._get_value_from_array(_adodb_query_data_in_number_mode($v_selectbox_option_sql),$v_selectbox_id_column,$v_selectbox_name_column,$v_value);
			}else{
			$i = 0;
				$arr_list_item = array();
				if (isset($_SESSION[$v_session_name])){
					foreach($_SESSION[$v_session_name] as $arr_item) {
						$arr_list_item[$i] = $arr_item;
						$i++;
					}
				}
				$v_ret_html = $v_ret_html ._get_value_from_array($arr_list_item,$v_session_id_index,$v_session_name_index,$v_value);
			}
			break;
		default:
			$v_ret_html = "";
	}	
	return $v_ret_html;
}
?>